package bigdata.backend.utils;

import lombok.Getter;

/**
 * 全局统一响应码枚举
 * <p>
 * 包含系统通用码 + 数据源模块专用码
 */
@Getter
public enum ResultCodeEnum {

    // ========== 通用成功/失败 ==========
    SUCCESS(200, "success"),
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未认证"),
    FORBIDDEN(403, "无权限访问"),
    NOT_FOUND(404, "资源不存在"),
    INTERNAL_ERROR(500, "服务器内部错误"),

    // ========== 数据源模块 ==========
    DATASOURCE_NOT_FOUND(1001, "数据源不存在"),
    DATASOURCE_ALIAS_CONFLICT(1002, "数据源别名冲突"),
    DATASOURCE_REGISTER_FAILED(1003, "数据源注册失败"),
    DATASOURCE_UNREGISTER_FAILED(1004, "数据源移除失败"),

    // ========== 表结构同步 ==========
    TABLE_NAME_EMPTY(2001, "表名不能为空"),
    TABLE_ALREADY_EXISTS(2002, "目标表已存在，禁止覆盖"),
    SYNC_TO_SELF_FORBIDDEN(2003, "禁止将表同步到自身"),
    SCHEMA_SYNC_FAILED(2004, "表结构同步失败"),
    DDL_GENERATE_FAILED(2005, "建表语句生成失败"),

    // ========== SQL 执行 ==========
    SQL_NOT_SELECT(3001, "仅支持 SELECT 查询"),
    SQL_NOT_DML(3002, "仅支持 INSERT/UPDATE/DELETE 语句"),
    SQL_NOT_DDL(3003, "仅支持 CREATE/ALTER/DROP/TRUNCATE/COMMENT 语句"),
    SQL_EXECUTION_ERROR(3004, "SQL 执行出错"),

    // ========== Doris 元数据模块 ==========
    META_NOT_FOUND(4001, "本地元数据未找到，请先保存表结构"),
    META_TABLE_EXISTS(4002, "本地已存在该表元数据"),
    META_COMPARE_FAILED(4003, "元数据比对失败"),
    META_SYNC_FAILED(4004, "元数据同步失败"),
    META_INVALID_DIFF_TYPE(4005, "不支持的差异类型");

    private final Integer code;
    private final String message;

    ResultCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

}